import request from "../../utils/request.ts";
import {HospitalInfo, HospitalLevelOrRegionResponseData, HospitalResponseData} from "./type.ts";

enum API_URL{
  //获取医院列表
  HOSPITAL_LIST_URL = '/hosp/hospital/',
  HOSPITAL_LEVEL_OR_REGION_URL = '/cmn/dict/findByDictCode/',
  HOSPITAL_INFO_URL = '/hosp/hospital/findByHosname/',

}
/*
* ### 获取医院列表
* @param pageNo 页码
* @param pageSize 每页条数
* @param hostype 医院等级
* @param districtCode 地区编码
* @return HospitalResponseData 医院列表
*/
export const reqHospitalList = (pageNo:number,pageSize:number,hostype='',districtCode='')=>{
  return request.get<any,HospitalResponseData>(API_URL.HOSPITAL_LIST_URL + pageNo + "/" + pageSize+
  "?hostype="+hostype+"&districtCode="+districtCode);
}

/**
 * ### 获取医院等级与地区列表
 * @param dictCode 字典编码
 * @return HospitalLevelOrRegionResponseData 医院等级或地区列表
 */
export const reqHospitalLevelOrRegion = (dictCode:string)=>{
  return request.get<any,HospitalLevelOrRegionResponseData>(API_URL.HOSPITAL_LEVEL_OR_REGION_URL + dictCode);
}
/**
 * ### 根据医院名字关键字获取医院数据
 * @param hosname 医院名字
 * @return HospitalInfo 医院数据
 */
export const reqHospitalInfo = (hosname:string)=>{
  return request.get<any,HospitalInfo>(API_URL.HOSPITAL_INFO_URL + hosname);
}
